package com.yf.dxapp.module.app.dal.mysql.token;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.yf.dxapp.module.app.controller.admin.token.vo.TokenPageReqVO;
import com.yf.dxapp.module.app.dal.dataobject.token.TokenDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 登录token Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TokenMapper extends BaseMapperX<TokenDO> {

    default PageResult<TokenDO> selectPage(TokenPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TokenDO>()
                .eqIfPresent(TokenDO::getUserId, reqVO.getUserId())
                .eqIfPresent(TokenDO::getToken, reqVO.getToken())
                .betweenIfPresent(TokenDO::getExpireTime, reqVO.getExpireTime())
                .eqIfPresent(TokenDO::getType, reqVO.getType())
                .betweenIfPresent(TokenDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TokenDO::getId));
    }

}